package com.cml.rpc.client;

import com.cml.rpc.publicinterface.UserService;
import com.cml.rpc.publicpojo.User;

/**
 * 客户端入口
 * 重构结构，松解耦，不同通信方式不同实现
 * 使用netty进行通信
 * @author cml
 *
 * @create 2021/7/21 12:57
 */
public class RpcClientMain {
    public static void main(String[] args) {
//        RpcClient simpleRpcClient = new SimpleRpcClient("127.0.0.1", 8877);
//        RpcClientProxy rpcClientProxy = new RpcClientProxy(simpleRpcClient);

        NettyRpcClient nettyRpcClient = new NettyRpcClient("127.0.0.1", 8877);
        RpcClientProxy rpcClientProxy = new RpcClientProxy(nettyRpcClient);
        UserService proxyUserService = rpcClientProxy.getProxy(UserService.class);
        User user = proxyUserService.getUserById(123);
        System.out.println("user = " + user);
        User userById = proxyUserService.getUserById(124);
        System.out.println("user2 = " + userById);


    }
}
